package com.trhui.mallbook.client;

import com.trhui.mallbook.domain.common.ApiRequest;
import com.trhui.mallbook.domain.common.BaseResponse;
import com.trhui.mallbook.domain.request.hf.*;
import com.trhui.mallbook.domain.response.hf.*;
import com.trhui.mallbook.enums.ChannelTypeEnum;
import com.trhui.mallbook.enums.ServerCodeEnum;

/**
 * 快捷支付相关接口
 * @Author xgc
 * @Date 2023/08/28 15:10
 **/
public class FastPayClient extends AbstractClient {
    /**
     * 汇付-快捷绑卡申请
     *
     * @param request 快捷绑卡申请的请求参数，参见 api
     * @return
     */
    public static BaseResponse<HfFastBindApplyResponse> hfCardApply(HfFastBindApplyRequest request) {
        ApiRequest reqApiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.FAST_BIND_APPLY)
                .channelType(ChannelTypeEnum.HF)
                .build();
        return post(reqApiRequest, HfFastBindApplyResponse.class);
    }

    /**
     * 汇付-快捷绑卡确认
     *
     * @param request 快捷绑卡确认的请求参数，参见 api
     * @return
     */
    public static BaseResponse<HfFastBindConfirmResponse> hfCardConfirm(HfFastBindConfirmRequest request) {
        ApiRequest reqApiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.FAST_BIND_CONFIRM)
                .channelType(ChannelTypeEnum.HF)
                .build();
        return post(reqApiRequest, HfFastBindConfirmResponse.class);
    }

    /**
     * 汇付-解绑快捷卡
     *
     * @param request 解绑快捷卡的请求参数，参见 api
     * @return
     */
    public static BaseResponse<HfFastUnbindResponse> hfFastUnbind(HfFastUnbindRequest request) {
        ApiRequest reqApiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.FAST_UNBIND)
                .channelType(ChannelTypeEnum.HF)
                .build();
        return post(reqApiRequest, HfFastUnbindResponse.class);
    }


    /**
     * 汇付-快捷支付短信重发
     *
     * @param request 快捷支付短信重发的请求参数，参见 api
     * @return
     */
    public static BaseResponse<HfFastPaySendSmsResponse> hfSmsCode(HfFastPaySendSmsRequest request) {
        ApiRequest reqApiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.FAST_PAY_SEND_SMS)
                .channelType(ChannelTypeEnum.HF)
                .build();
        return post(reqApiRequest, HfFastPaySendSmsResponse.class);
    }


    /**
     * 汇付-快捷支付确认接口
     *
     * @param request
     * @return
     */
    public static BaseResponse<HfFastPayConfirmResponse> hfFastPaySendSms(HfFastPayConfirmRequest request) {
        ApiRequest reqApiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.FASTPAY_CONFIRM)
                .channelType(ChannelTypeEnum.HF)
                .build();
        return post(reqApiRequest, HfFastPayConfirmResponse.class);
    }

    /**
     * 汇付-快捷卡查询
     *
     * @param request
     * @return
     */
    public static BaseResponse<HfFastCardQueryResponse> hfQueryFastCard(HfQueryFastCardRequest request) {
        ApiRequest reqApiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.QUERY_FAST_CARD)
                .channelType(ChannelTypeEnum.HF)
                .build();
        return post(reqApiRequest, HfFastCardQueryResponse.class);
    }
}
